% This file generates Figure 12 in the paper. It calls 
% 'FIG_12_Robustness_Theory_Persistence_solve.m' which is the file that
% solves the model itself. 

close all; clc; clear;

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%           Obtaining the resutls           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%
rho         =   0.97;

run FIG_12_Robustness_Theory_Persistence_solve.m

IY0         =   [yf(1:T-1) irfy3(1:T-1) irfy6(1:T-1) irfy10(1:T-1)];
IP0         =   [pif(2:T) irfpi3(2:T) irfpi6(2:T) irfpi10(2:T)];
A0          =   a(1:T-1);

%%
rho                     = 0.75;

run FIG_12_Robustness_Theory_Persistence_solve.m

IY1         =   [yf(1:T-1) irfy3(1:T-1) irfy6(1:T-1) irfy10(1:T-1)];
IP1         =   [pif(2:T) irfpi3(2:T) irfpi6(2:T) irfpi10(2:T)];
A1          =   a(1:T-1);

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%           Plotting results                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t           =   0:T-2;

figure
subplot(2,2,1)
plot(t,A0,'--k',t,A1,':k',t,IY0(:,1),'--b',t,IY1(:,1),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 0$','Interpreter','latex','fontSize',14)
h = legend('$A, \rho_{A} = 0.97$','$A, \rho_{A} = 0.75$','$Y, \rho_{A} = 0.97$','$Y, \rho_{A} = 0.75$','Location','SouthEast');
set(h,'Interpreter','latex')
grid on
set(gca,'layer','top')
subplot(2,2,2)
plot(t,A0,'--k',t,A1,':k',t,IY0(:,2),'--b',t,IY1(:,2),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 3$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,3)
plot(t,A0,'--k',t,A1,':k',t,IY0(:,3),'--b',t,IY1(:,3),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 6$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,4)
plot(t,A0,'--k',t,A1,':k',t,IY0(:,4),'--b',t,IY1(:,4),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 10$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')

figure
subplot(2,2,1)
plot(t,A0,'--k',t,A1,':k',t,IP0(:,1),'--b',t,IP1(:,1),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 0$','Interpreter','latex','fontSize',14)
h = legend('$A, \rho_{A} = 0.97$','$A, \rho_{A} = 0.75$','$\pi^{e}, \rho_{A} = 0.97$','$\pi^{e}, \rho_{A} = 0.75$','Location','SouthEast');
set(h,'Interpreter','latex')
grid on
set(gca,'layer','top')
subplot(2,2,2)
plot(t,A0,'--k',t,A1,':k',t,IP0(:,2),'--b',t,IP1(:,2),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 3$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,3)
plot(t,A0,'--k',t,A1,':k',t,IP0(:,3),'--b',t,IP1(:,3),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 6$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,4)
plot(t,A0,'--k',t,A1,':k',t,IP0(:,4),'--b',t,IP1(:,4),':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 10$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')

figure
subplot(2,2,1)
plot(t,IY0(:,1)-A0,'--b',t,IY1(:,1)-A1,':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 0$','Interpreter','latex','fontSize',14)
h = legend('$Y-A, \rho_{A} = 0.97$','$Y-A, \rho_{A} = 0.75$','Location','SouthEast');
set(h,'Interpreter','latex')
grid on
set(gca,'layer','top')
subplot(2,2,2)
plot(t,IY0(:,2)-A0,'--b',t,IY1(:,2)-A1,':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 3$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,3)
plot(t,IY0(:,3)-A0,'--b',t,IY1(:,3)-A1,':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 6$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')
subplot(2,2,4)
plot(t,IY0(:,4)-A0,'--b',t,IY1(:,4)-A1,':b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('$H = 10$','Interpreter','latex','fontSize',14)
grid on
set(gca,'layer','top')


figure
subplot(2,2,1)
plot(t,IY0(:,1),'-b',t,IY0(:,2),':b',t,IY0(:,3),'--b',t,IY0(:,4),'-.b','Linewidth',1.5)
title('$\rho_{A} = 0.97$','Interpreter','latex','fontSize',14)
ylabel('Output','Interpreter','latex','fontSize',14)
ylim([-1.0 1.0])
h = legend('$H = 0$','$H = 3$','$H = 6$','$H = 10$','Location','SouthEast');
set(h,'Interpreter','latex')
grid on
set(gca,'layer','top')
subplot(2,2,2)
plot(t,IY1(:,1),'-b',t,IY1(:,2),':b',t,IY1(:,3),'--b',t,IY1(:,4),'-.b','Linewidth',1.5)
title('$\rho_{A} = 0.75$','Interpreter','latex','fontSize',14)
ylim([-1.0 1.0])
grid on
set(gca,'layer','top')
subplot(2,2,3)
plot(t,IP0(:,1),'-b',t,IP0(:,2),':b',t,IP0(:,3),'--b',t,IP0(:,4),'-.b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylabel('Expected Inflation','Interpreter','latex','fontSize',14)
ylim([-0.4 0.0])
grid on
set(gca,'layer','top')
subplot(2,2,4)
plot(t,IP1(:,1),'-b',t,IP1(:,2),':b',t,IP1(:,3),'--b',t,IP1(:,4),'-.b','Linewidth',1.5)
xlabel('Horizon','Interpreter','latex','fontSize',14)
ylim([-0.4 0.0])
grid on
set(gca,'layer','top')
